<template>
  <div class="toolBar">
    <div class="menus">
      <div v-for="menu in menus" :key="menu.value" class="module" @click="onClick(menu)">
        <el-button link class="buttons">
          <span>{{ menu.label }}</span>
        </el-button>
      </div>
      <slot name="other" />
    </div>
    <slot name="right" />
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';

defineOptions({
  name: 'ToolBar',
});

const props = defineProps({
  menus: {
    type: Object,
    default: () => {},
  },
});
const emailDetail = ref<any>(null);
const emit = defineEmits(['onClick']);
const onClick = (row: any) => {
  emit('onClick', row, emailDetail.value)
};
</script>
<style lang="scss" scoped>
.toolBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 15px;
  background: #eee;
  border-top-left-radius: 2px;
  border-top-right-radius: 2px;

  .menus {
    display: flex;

    .module {
      position: relative;
      display: flex;
      align-items: center;
      height: 30px;
      border: 1px solid rgb(255 255 255 / 0%);

      .buttons {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        height: 100%;
        padding: 0 10px;
        font-size: 12px;

        & > span {
          margin-left: 6px;
        }
      }

      &::after {
        position: absolute;
        top: 28px;
        left: 0;
        width: 100%;
        height: 2px;
        content: "";
      }

      &:hover {
        background: linear-gradient(#daecfc, #b9cfe5);
        border: 1px solid #99b2cb;
        border-radius: 3px;
        box-shadow: 0 0 6px rgb(0 0 0 / 12%);
      }
    }
  }
}
</style>
